//
// Created by liushuai on 12/22/19.
//
#include "Node.h"
#include "reverseLinklist.h"
Node *reverseLinklist(Node *head) {
    Node *currentNode = head;
    Node *preNode = nullptr;
    Node *tailNode = nullptr;
    while (currentNode) {
        Node *nextNode = currentNode->next;
        if (!nextNode)
            tailNode = currentNode;
        currentNode->next = preNode;
        preNode = currentNode;
        currentNode = nextNode;
    }
    return tailNode;
};
